package Date;

import java.awt.event.MouseAdapter;
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;
import Model.Index;



public class ArrangeView {
  /* {src_lang=Java}*/


  private Map<String, Object> params;
  private int actualYear;
  private int actualWeek;
  private int actualDay;
  private int actualMonth;
  private int selectedEvents;
  private String dayof;
  private int view;
  private final String month[] = {"Jun", "Feb", "Mar", "Apr", "May","Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  private ArrayList<Index> day;
  
  
  public ArrangeView(int view, int actualYear, int actualweek, int actualday, int acualmonth, int selectedevents)
  {
	  this.actualMonth=acualmonth;
	  this.selectedEvents=selectedevents;
	  this.actualDay=actualday;
	  this.actualWeek=actualweek;
	  this.actualYear=actualYear;
	  this.view=view;
	  params = new Hashtable<String, Object>();
	  params.put("Moodle", true);
	  params.put("Normal", true);
  }
  	public void alterDate(int day)
  	{
  		Calendar cal = Calendar.getInstance();
  		
  		if(view==0)
  		{
  			cal.set( actualYear, actualMonth,actualDay+(day==1?-1:1));
  		}
  		else if(view==1)
  		{
  			cal.set( actualYear, actualMonth,actualDay+(day==1?-7:7));
  		}
  		else if(view==2)
  			cal.set(actualYear, actualMonth+(day==1?-1:1), actualDay);
  		
  		actualDay=cal.get(Calendar.DAY_OF_MONTH);
  		actualWeek=cal.get(Calendar.WEEK_OF_YEAR);
  		actualYear=cal.get(Calendar.YEAR);
  		actualMonth=cal.get(Calendar.MONTH);
  		System.out.println();
  	}
	public int getActualMonth() {
		return actualMonth;
	}

	public void setActualMonth(int actualMonth) {
		this.actualMonth = actualMonth;
	}
	
	public int getSelectedEvents() {
		return selectedEvents;
	}
	
	public void setSelectedEvents(int selectedEvents) {
		this.selectedEvents = selectedEvents;
	}

	public int getActualYear() {
		return actualYear;
	}
	
	public void setActualYear(int actualYear) {
		this.actualYear = actualYear;
	}
	
	public int getActualweek() {
		return actualWeek;
	}
	
	public void setActualweek(int actualweek) {
		this.actualWeek = actualweek;
	}
	
	public int getActualDay() {
		return actualDay;
	}
	
	public void setActualDay(int actualDay) {
		this.actualDay = actualDay;
	}
	
	public int getView() {
		return view;
	}
	
	public void setView(int view) {
		this.view = view;
	}
	
	public ArrayList<Index> getDay() {
		return day;
	}
	
	public void setDay(ArrayList<Index> day) {
		this.day = day;
	}
	
	public Map<String, Object> getParams() {
		return params;
	}
	
	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

	public int getCurrentMonth() {
		return actualYear*(actualMonth+1);
	}
	public String getName()
	{
		String nombre="";
		if(view==0)
		{
//			Calendar cal = Calendar.getInstance();
//			cal.set(actualYear, actualMonth, actualDay);
			nombre+= month[actualMonth] + " "+actualDay+" "+actualYear; 
		}
		else if(view==1)
		{
			Calendar cal = Calendar.getInstance();
			cal.set(actualYear, actualMonth, actualDay);
			Date in = new Date(actualYear, actualMonth, actualDay-(cal.get(Calendar.DAY_OF_WEEK))+1);
			Date fin = new Date(actualYear, actualMonth, actualDay-(cal.get(Calendar.DAY_OF_WEEK))+7);
			int inicio = cal.get(Calendar.DAY_OF_WEEK);
			dayof = new java.text.DateFormatSymbols().getWeekdays()[inicio];
			nombre+= month[in.getMonth()] + " "+in.getDate()+" "+actualYear +" - "+ month[fin.getMonth()] + " "+fin.getDate()+" "+actualYear; 
		}
		else if(view==2)
		{
			nombre+= month[actualMonth] + " "+actualYear;
		}
		return nombre;
	}
	public String getDayName() {
		// TODO Auto-generated method stub
		return dayof;
	}
	
	
}